var columns = [
    {
        field: 'index',
        title: '序号',
        align:"center",
        formatter:function(value, row, index){
            return index + 1 + (row.pageNumber-1)*row.pageSize;
        }
    },{
        field: 'loginName',
        align: 'center',
        title: '登陆名称'
    },{
        field: 'trueName',
        align: 'center',
        title: '真实名称'
    },{
        field: 'cityName',
        align: 'center',
        title: '所属地市'
    },{
        field: 'sex',
        title: '用户性别',
        align: 'center',
        formatter: function (value, row, index) {
            return pubForm.getSex(row.sex);
        }
    },{
        field: 'tel',
        align: 'center',
        title: '电话号码'
    },{
        field: 'duty',
        title: '所属职位',
        align: 'center',
        formatter: function (value, row, index) {
            return pubForm.getDuty(row.duty);
        }
    },{
        field: 'createTime',
        align: 'center',
        title: '创建时间'
    },{
        field: 'state',
        title: '是否启用',
        align: 'center',
        formatter: function (value, row, index) {
            return pubSwitch.getSwitchBtnCss(row);
        }
    },{
        field: 'operator',
        title: '操作',
        align: 'center',
        formatter: function (value, row, index) {
            return pubOptBtn.getOptBtn2('user',menu,row.id,type);
        }
    }];

var user={
    userInit:function() {
        pubOptBtn.getHeadBtn("p","#headBtn","user",menu);
        if('1' == type){
            pubForm.getBootTable("#tableList","/schoolmaster/querySchoolMasterUser","/user/updateState");
        }
        else if('2' == type){
            pubForm.getBootTable("#tableList","/teacher/queryTeacherUser","/user/updateState");
        }
        else if('3' == type){
            pubForm.getBootTable("#tableList","/student/queryStudent","/user/updateState");
        }else{
            pubForm.getBootTable("#tableList","/user/queryAll","/user/updateState");
        }
    },
    showUpdateMasterPage:function (userId) {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showUpdateMasterPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    showSMasterPage:function(userId){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showSMasterPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    //打开添加页面
    showMasterAddPage:function () {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showMasterAddPage?menuId="+menuId+"&type="+type+"&type="+stype,
        });
    },

    showUpdateTeacherPage:function (userId) {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showUpdateTeacherPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    showSTeacherPage:function(userId){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showSTeacherPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    //打开添加页面
    showTeacherAddPage:function () {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showTeacherAddPage?menuId="+menuId+"&type="+type+"&type="+stype,
        });
    },

    showUpdateStudentPage:function (userId) {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showUpdateStudentPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    showSStudentPage:function(userId){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showSStudentPage?menuId="+menuId+"&userId="+userId+"&type="+stype
        });
    },
    //打开添加页面
    showStudentAddPage:function () {
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/user/showStudentAddPage?menuId="+menuId+"&type="+type+"&type="+stype,
        });
    },


    delUser:function (userId) {
        pubForm.delRow(userId,"/user/delUser","/user/queryAll","#tableList");
    },
    queryUserByUserName:function () {
        //alert($(".page-size").text());
        var opt={
            url:application.contextPath+"/user/queryUserByUserName?type="+type,
            query:{size:5,page:1,sel:$("#selectText").val()},
            silent:true
        };
        $('#tableList').bootstrapTable('refresh',opt);
        $("#selectText").val("");
    }
};

$(document).ready(function(){
    user.userInit();
});